//
//  DB.m
//  项目
//
//  Created by 焦钟培 on 15-1-6.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "DB.h"
#import <sqlite3.h>

static sqlite3 *dbpoint = nil;

@implementation DB
+ (sqlite3 *)openDB
{
    if (dbpoint) {
        return dbpoint;
    }else{
        NSFileManager *manager = [NSFileManager defaultManager];
        NSArray *array = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString *path = [NSString stringWithFormat:@"%@/Detail.rdb",[array firstObject]];
//        NSLog(@"%@",path);
        if (![manager fileExistsAtPath:path]) {
            NSString *soure = [[NSBundle mainBundle] pathForResource:@"detail" ofType:@"rdb"];
            [manager copyItemAtPath:soure toPath:path error:nil];
        }
        sqlite3_open([path UTF8String], &dbpoint);
        return dbpoint;
    }
    return dbpoint;
}

@end
